﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MGI/Map24MGI.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


//coordinates of the Oval to add
$longitude 	= "598.3";
$latitude 	= "3213.0068";
$width		= "3000";
$height		= "3000";

//Color of the Oval (Fillcolor)
$FillColor['red'] = 255;
$FillColor['green'] = 0;
$FillColor['blue'] = 0;
$FillColor['alpha'] = 30;

//Color of the Border (Bordercolor)
$BorderColor['red'] = 0;
$BorderColor['green'] = 0;
$BorderColor['blue'] = 255;
$BorderColor['alpha'] = 255;

// discription
$discription = "Oval Hamburg";

// zoomlevel
$mapViewClippingWidth = 3000;

//MGI Settings
$ImageWidth=800;
$ImageHeight=600;
$MimeType='image/gif';


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new Oval
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Oval = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Oval->MapObjectID = "Oval";
$commands[$cmdIdx]->DeclareMap24Oval->Center = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Oval->Center->Longitude = $longitude;
$commands[$cmdIdx]->DeclareMap24Oval->Center->Latitude = $latitude;
$commands[$cmdIdx]->DeclareMap24Oval->Width= $width;
$commands[$cmdIdx]->DeclareMap24Oval->Height= $height;
$commands[$cmdIdx]->DeclareMap24Oval->FillColor = new Color();
$commands[$cmdIdx]->DeclareMap24Oval->FillColor->red = $FillColor['red'];
$commands[$cmdIdx]->DeclareMap24Oval->FillColor->green = $FillColor['green'];
$commands[$cmdIdx]->DeclareMap24Oval->FillColor->blue = $FillColor['blue'];
$commands[$cmdIdx]->DeclareMap24Oval->FillColor->alpha = $FillColor['alpha'];
$commands[$cmdIdx]->DeclareMap24Oval->BorderColor = new Color();
$commands[$cmdIdx]->DeclareMap24Oval->BorderColor->red = $BorderColor['red'];
$commands[$cmdIdx]->DeclareMap24Oval->BorderColor->green = $BorderColor['green'];
$commands[$cmdIdx]->DeclareMap24Oval->BorderColor->blue = $BorderColor['blue'];
$commands[$cmdIdx]->DeclareMap24Oval->BorderColor->alpha = $BorderColor['alpha'];
$commands[$cmdIdx]->DeclareMap24Oval->Description = $description;

// this object will enable the new Oval on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "SHOW";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("Oval");

// this object will center the map above the new Oval
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("Oval");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new RenderBitmapImageRequest();
$request->MRC = new Map24MRC();
$request->MRC->Commands = $commands;
$request->BitmapDescriptor= new BitmapDescriptor();
$request->BitmapDescriptor->ImageWidth=$ImageWidth;
$request->BitmapDescriptor->ImageHeight=$ImageHeight;
$request->BitmapDescriptor->MimeType=$MimeType;



// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed

$mrc = new Map24MGI($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->renderBitmapImage($header,$request);


// ------------------------------------------------------------------
// SAVE IMG DATA IN THE SESSION
// ------------------------------------------------------------------


// Save the BitmapData in the Session, to show it in another file
$_SESSION['IMG']=base64_encode($response->BitmapData);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


if(isset($response->BitmapData) )
{
	$resultString = "<img src='./img.php?".SID."' border='0'>";
}
else
{
	$resultString = "Sorry, no answer from the Webservices";
}

?>